package cn.yunhe.study.dubbo.api;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import java.io.IOException;
@Component
public class CustomerStart {
    @Reference(version = "1.0")
    private static IDemoService demoService;
    public static void main(String[] args) {
        /*注解的方式进行*/
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"dubbo_consumer.xml"});
        System.out.println(demoService.sayHello("张三"));
        System.out.println(demoService.getUser(new User("李四",25)));
        //配置文件方式
        /*try{
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"dubbo_consumer.xml"});
            context.start();
            IDemoService iDemoService = (IDemoService) context.getBean("IDemoService");
            System.out.println(iDemoService.sayHello("zhangsan"));
            synchronized (CustomerStart.class) {
                try {
                    CustomerStart.class.wait();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }*/

    }
}
